package lab1;

import static org.junit.Assert.*;

import org.junit.Test;

public class MyArrayListTest {

	@Test
	public void testSize() {
		MyArrayList ArrList = new MyArrayList();
		assertEquals(0, ArrList.size());
		ArrList.add(1);
		ArrList.add(2);
		assertEquals(2, ArrList.size());
		ArrList.remove(0);
		assertEquals(1, ArrList.size());
	}
	@Test
	public void testIsEmpty(){
		MyArrayList ArrList = new MyArrayList();
		assertTrue(ArrList.isEmpty());
		ArrList.add(1);
		ArrList.add(2);
		ArrList.remove(0);
		assertFalse(ArrList.isEmpty());
		ArrList.remove(0);
		assertTrue(ArrList.isEmpty());
	}

	@Test
	public void testAddInteger() {
		MyArrayList ArrList = new MyArrayList();
		assertTrue(ArrList.add(1));
		assertTrue(ArrList.add(1));
	}

	@Test
	public void testGetInt() {
		MyArrayList ArrList = new MyArrayList();
		ArrList.add(1);
		ArrList.add(2);
		ArrList.add(3);
		assertEquals(1, (int)ArrList.get(0));
		ArrList.remove(0);
		assertEquals(2, (int)ArrList.get(0));
	}

	@Test
	public void testRemoveInt() {
		MyArrayList ArrList = new MyArrayList();
		ArrList.add(1);
		ArrList.add(2);
		ArrList.add(3);
		assertEquals(1, (int)ArrList.remove(0));
		assertEquals(2, (int)ArrList.remove(0));
	}

	@Test
	public void testRemoveEl() {
		MyArrayList ArrList = new MyArrayList();
		ArrList.add(1);
		ArrList.add(2);
		ArrList.add(3);
		assertTrue(ArrList.removeEl(1));
		assertFalse(ArrList.removeEl(4));
	}

}
